<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function userState(Nstate) {
        let state = [];
        let count = 0;   
          state[count] = Nstate;
        function setState(Nstate) {
          state[count] = Nstate;
          console.log(state,"====原本值");
        }      
        return [state[count++], setState];
      }
        function comA() {
          const [num,setNum] = userState(0)
          setNum(10)
            console.log(num,"=====");
        }
        comA();
        comA();
        function comB() {
          const [num, setNum] = userState(100);
        }
    </script>
  </body>
</html>
